<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\helpers\ActionButton;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\LibraryBookSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Библиотека';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="container library-book-index">

    <h1 class="main-title"><?= Html::encode($this->title) ?></h1>

    <div class="action-menu action-menu__container">
        <div>
        <?= ActionButton::create('Добавить книгу', 'createLibraryBook') ?>
        </div>
        <div>
            <?= ActionButton::dictionaryLink('Коллекции', 'library-collection/index', 'browseLibraryCollection');?>
            <?= ActionButton::dictionaryLink('Типы сохранности книг', 'library-condition/index', 'browseLibraryCondition');?>
            <?= ActionButton::dictionaryLink('Коды ББК', 'library-bbk/index', 'browseLibraryBbk');?>
            <?= ActionButton::dictionaryLink('Коды УДК', 'library-udk/index', 'browseLibraryUdk');?>
        </div>
    </div>

    <?php echo $this->render('_search', ['model' => $searchModel]); ?>

</div>

<div class="container contract-table-container">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'tableOptions' => [
            'class' => 'table table-striped'
        ],
        'filterModel' => $searchModel,
        'columns' => [
            'author',
            'title',
            'year',
            'annotation:ntext',

            [
                'class' => 'yii\grid\ActionColumn',
                'visibleButtons' =>
                [
                    'view' => Yii::$app->user->can('browseLibraryBook'),
                    'update' => Yii::$app->user->can('updateLibraryBook'),
                    'delete' => Yii::$app->user->can('deleteLibraryBook'),
                ]
            ],
        ],
    ]); ?>


</div>
